package com.yixun.qfbao.hander;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.GetQiniuUploadTokenService;
import com.yixun.qfbao.apidto.GetQiniuUploadTokenResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetQiniuUploadTokenReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * @author zilong.liu
 * @date 2020-10-26
 *
 * desc:
 *     	获取七牛上传凭证
 */
@Service("getQiniuUploadTokenHander")
public class GetQiniuUploadTokenHander extends CommonAbstractHander{

	@Autowired
	GetQiniuUploadTokenService getQiniuUploadTokenService;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetQiniuUploadTokenReqVo reqVo = (GetQiniuUploadTokenReqVo) reqDto;
		int castRefersh = reqVo.getParams().getCastRefresh();
		String uploadToken = getQiniuUploadTokenService.getQiniuUploadToken(castRefersh);
		BaseResponseDTO<GetQiniuUploadTokenResDto> resDto = new BaseResponseDTO<>();
		GetQiniuUploadTokenResDto getQiniuUploadTokenResDto = new GetQiniuUploadTokenResDto();
		getQiniuUploadTokenResDto.setUploadToken(uploadToken);
		resDto.setResData(getQiniuUploadTokenResDto);
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

}
